package servlet;

import com.fasterxml.jackson.databind.ObjectMapper;
import service.HouseholdrService;
import service.impl.HouseholdServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @author pengrui
 * @version 1.0
 * @date 2021/9/10 16:10
 * @Description //household前后端数据交互
 */
@WebServlet("/DeleteHouseholdServlet")
public class DeleteHouseholdServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String id=request.getParameter("id");
        HouseholdrService householdrService=new HouseholdServiceImpl();
        PrintWriter printWriter=response.getWriter();
        printWriter.print(new ObjectMapper().writeValueAsString(householdrService.deleteHousehold(id)));
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
